<template>
	<view class="content">
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="info-item" v-for="(item,index) in list" :key="item.id">
					<view class="title-item">
						<view class="name">{{item.duties}}:{{item.name}}</view>
						<view @click="list[index].more=!item.more" class="time">{{item.more?'【收起】':'【展开】'}}</view>
					</view>
					<view class="time-item" :class="item.more?'':'fewer'">
						<template v-if="item.report.length>0">
							<view v-for="(item1,index1) in item.report" :key="item1.id" class="one">
								<view class="onedot"></view>
								<view class="oneline"></view>
								<view class="onemain">
									<view style="display: flex;flex-direction: row;align-items: center;">
										<view class="onemaintitle">{{item1.startTime}}</view>
										<view class="onemaintitle" v-if="item1.time==1" style="margin-left: 15rpx;">上午
										</view>
										<view class="onemaintitle" v-else-if="item1.time==2"
											style="margin-left: 15rpx;">下午</view>
										<view class="onemaintitle" style="margin-left: 15rpx;" v-if="item1.location">
											{{item1.location}}
										</view>
									</view>
									<view class="onemaincon">{{item1.report}}</view>
								</view>
							</view>
						</template>
						<view v-else style="text-align: center;" class="time-item" :class="item.more?'':'fewer'">暂无数据
						</view>
					</view>
				</view>
			</template>
			<view v-else style="text-align: center;">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		getAllListApi
	} from '@/api/supervise.js'

	export default {
		data() {
			return {
				list: [],
				name: '',
				id: null,
			}
		},
		methods: {
			search() {
				this.getList()
			},
			bindStart(e) {
				this.workTimeStart = e.detail.value
				if (this.workTimeEnd != '结束日期') {
					this.getList()
				}
			},
			bindEnd(e) {
				this.workTimeEnd = e.detail.value
				if (this.workTimeStart != '开始日期') {
					this.getList()
				}
			},
			getList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getAllListApi({
					id: this.id,
					name: this.name,
				}).then(res => {
					uni.hideLoading()
					let list = res.list || [];
					list.forEach((item, index) => {
						item.more = false;
					})
					this.list = list
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		onLoad(e) {
			this.id = e.id
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F5F5F5;
		width: 100%;
		min-height: 100vh;
		padding: 30rpx;

		.search-block {
			position: relative;
			width: 100%;
			height: 60rpx;
			padding: 30rpx 0;
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 30rpx;

			.input-block {
				width: 100%;
				display: flex;
				flex-direction: row;
				align-items: center;
				border: 1px solid #808080;
				border-radius: 40rpx;
				padding: 0 10rpx;
				height: 60rpx;

				.iconfont {
					flex-grow: 0;
					color: #808080;
					margin: 0 10rpx;
				}

				input {
					flex-grow: 1;
					font-size: 28rpx;
					color: #808080;
					margin: 0 10rpx;
				}
			}
		}

		.form-content {
			display: flex;
			flex-direction: row;
			justify-content: center;
			margin-bottom: 20rpx;

			.form-ctrl {
				margin-left: 10rpx;
				font-size: 30rpx;
				color: #999;
			}
		}

		.info-block {
			display: flex;
			flex-direction: column;
			height: auto;
			position: relative;

			.info-item {
				min-height: 160rpx;
				height: auto;
				box-shadow: 0 0 10px 0 #dedede;
				background: #fff;
				display: flex;
				flex-direction: column;
				justify-content: center;
				border-radius: 20rpx;
				padding: 20rpx;
				margin-bottom: 30rpx;


				.title-item {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;

					.name {
						width: calc(100% - 150rpx);
						font-weight: bold;
						font-size: 34rpx;
					}

					.time {
						font-size: 28rpx;
						color: $uni-color-primary;
					}
				}


				.time-item.fewer {
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					overflow: hidden;
					display: none;
				}

				.time-item {
					background: #F8F8F8;
					margin-top: 20rpx;
					padding: 20rpx;
					border-radius: 20rpx;

					.one {
						position: relative;
						padding-bottom: 10rpx;

						.onedot {
							left: -2rpx;
							width: 24rpx;
							height: 24rpx;
							position: absolute;
							//background-color: #4C7FE2;
							border: 1px solid #4C7FE2;
							border-radius: 50%;
							display: flex;
							justify-content: center;
							align-items: center;
							z-index: 1;
						}

						.oneline {
							position: absolute;
							left: 10rpx;
							height: calc(100% - 24rpx);
							border-left: 1px solid #1254F1;
							margin-top: 24rpx;
						}

						.onemain {
							position: relative;
							padding-left: 56rpx;
							top: -6rpx;
						}

						.onemaintitle {
							margin-bottom: 16rpx;
							padding-top: 8rpx;
							line-height: 1;
							font-size: 28rpx;
							color: #303133;
						}

						.onemaincon {
							color: #303133;
							background-color: #DFE8F9;
							padding: 20rpx;
							font-size: 28rpx;
							line-height: 60rpx;
						}
					}
				}
			}
		}
	}
</style>